package com.etc.service;

import com.etc.dao.ADao;
import com.etc.pojo.EmpMst;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;

@Service("myService")
public class AService implements IService{

    @Autowired
    ADao aDao;

    // 切面
    // 如果方法调用别的service方法， 在同一个事务里，
    // 如果抛出异常的话会回滚
//    @Transactional(propagation= Propagation.REQUIRED , rollbackFor = Exception.class)
    public List<HashMap> aaaaaa() {
        // TODO 业务处理
        System.out.println("Aservice.aaaaaa()");

        List<HashMap> lll = aDao.findALL();
        return lll;
    }

    @Override
    public EmpMst findByName(String name) {
        return aDao.findByAAAName(name);
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED,rollbackFor = Exception.class)
    public int add(EmpMst emp) {
        return aDao.insert(emp);
    }
}
